/**
 * 4
 *  
 * @Author : Ruoyu Wang
 * @DateTime : 24-9-21 下午6:26
 */

#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>

using namespace std;

int main() {
    string s;
    cin >> s;
    stack<int> stk;
    stk.push(-1);
    int res = 0;
    for (int i = 0; i < s.size(); ++i) {
        if (s[i] == '(') {
            stk.push(i);
        } else {
            stk.pop();
            if (stk.empty()) {
                stk.push(i);
            } else {
                res = max(res, i - stk.top());
            }
        }
    }
    cout << res;
    return 0;
}